import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import {longLimtVal, longLimtValAndNotBlank, rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '班组编号',
    align:"center",
    dataIndex: 'code'
  },
   {
    title: '班组名称',
    align:"center",
    dataIndex: 'name'
   },
  {
    title: '部门',
    align:"center",
    dataIndex: 'departmentId_dictText'
  },
  {
    title: '班组人数',
    align:"center",
    dataIndex: 'personCount'
  },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },

];
//查询数据
export const searchFormSchema: FormSchema[] = [	{
  label: "班组名称",
  field: 'name',
  component: 'JInput',
},
  {
    label: '部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps:{
      checkStrictly: true,
      multiple:false
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '班组名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        {
          required: true,
          validator: (_, value) => {
            return longLimtValAndNotBlank(value, 12)
          }
        }
      ];
    },
  },
  {
    label: '部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps:{
      checkStrictly: true,
      multiple:false
    },
    dynamicRules: ({model,schema}) => {
      return [
        {
          required: true,
        }
      ];
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
        {
          validator: (_, value) => {
            return longLimtVal(value,100)
          },
        },
      ];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  }
  ];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '组名',order: 0,view: 'text', type: 'string',},
  remark: {title: '备注',order: 1,view: 'text', type: 'string',},
  code: {title: '分组编号',order: 2,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
